package com.facebook.drawee.generic;

import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import com.facebook.drawee.R.styleable;
import com.facebook.drawee.drawable.AutoRotateDrawable;
import com.facebook.drawee.drawable.ScalingUtils.ScaleType;
import javax.annotation.Nullable;

public class GenericDraweeHierarchyInflater
{
  @Nullable
  private static Drawable getDrawable(Context paramContext, TypedArray paramTypedArray, int paramInt)
  {
    int i = paramTypedArray.getResourceId(paramInt, 0);
    if (i == 0)
      return null;
    return paramContext.getResources().getDrawable(i);
  }

  private static RoundingParams getRoundingParams(GenericDraweeHierarchyBuilder paramGenericDraweeHierarchyBuilder)
  {
    if (paramGenericDraweeHierarchyBuilder.getRoundingParams() == null)
      paramGenericDraweeHierarchyBuilder.setRoundingParams(new RoundingParams());
    return paramGenericDraweeHierarchyBuilder.getRoundingParams();
  }

  @Nullable
  private static ScalingUtils.ScaleType getScaleTypeFromXml(TypedArray paramTypedArray, int paramInt)
  {
    switch (paramTypedArray.getInt(paramInt, -2))
    {
    default:
      throw new RuntimeException("XML attribute not specified!");
    case -1:
      return null;
    case 0:
      return ScalingUtils.ScaleType.FIT_XY;
    case 1:
      return ScalingUtils.ScaleType.FIT_START;
    case 2:
      return ScalingUtils.ScaleType.FIT_CENTER;
    case 3:
      return ScalingUtils.ScaleType.FIT_END;
    case 4:
      return ScalingUtils.ScaleType.CENTER;
    case 5:
      return ScalingUtils.ScaleType.CENTER_INSIDE;
    case 6:
      return ScalingUtils.ScaleType.CENTER_CROP;
    case 7:
    }
    return ScalingUtils.ScaleType.FOCUS_CROP;
  }

  public static GenericDraweeHierarchyBuilder inflateBuilder(Context paramContext, @Nullable AttributeSet paramAttributeSet)
  {
    return updateBuilder(new GenericDraweeHierarchyBuilder(paramContext.getResources()), paramContext, paramAttributeSet);
  }

  public static GenericDraweeHierarchy inflateHierarchy(Context paramContext, @Nullable AttributeSet paramAttributeSet)
  {
    return inflateBuilder(paramContext, paramAttributeSet).build();
  }

  public static GenericDraweeHierarchyBuilder updateBuilder(GenericDraweeHierarchyBuilder paramGenericDraweeHierarchyBuilder, Context paramContext, @Nullable AttributeSet paramAttributeSet)
  {
    boolean bool1 = true;
    boolean bool2 = true;
    boolean bool3 = true;
    boolean bool4 = true;
    int i = 0;
    int j = 0;
    TypedArray localTypedArray;
    if (paramAttributeSet != null)
      localTypedArray = paramContext.obtainStyledAttributes(paramAttributeSet, R.styleable.GenericDraweeHierarchy);
    while (true)
    {
      int m;
      int n;
      try
      {
        int k = localTypedArray.getIndexCount();
        m = 0;
        if (m >= k)
          break label665;
        n = localTypedArray.getIndex(m);
        if (n == R.styleable.GenericDraweeHierarchy_actualImageScaleType)
          paramGenericDraweeHierarchyBuilder.setActualImageScaleType(getScaleTypeFromXml(localTypedArray, n));
        else if (n == R.styleable.GenericDraweeHierarchy_placeholderImage)
          paramGenericDraweeHierarchyBuilder.setPlaceholderImage(getDrawable(paramContext, localTypedArray, n));
      }
      finally
      {
        localTypedArray.recycle();
      }
      if (n == R.styleable.GenericDraweeHierarchy_pressedStateOverlayImage)
      {
        paramGenericDraweeHierarchyBuilder.setPressedStateOverlay(getDrawable(paramContext, localTypedArray, n));
      }
      else if (n == R.styleable.GenericDraweeHierarchy_progressBarImage)
      {
        paramGenericDraweeHierarchyBuilder.setProgressBarImage(getDrawable(paramContext, localTypedArray, n));
      }
      else if (n == R.styleable.GenericDraweeHierarchy_fadeDuration)
      {
        paramGenericDraweeHierarchyBuilder.setFadeDuration(localTypedArray.getInt(n, 0));
      }
      else if (n == R.styleable.GenericDraweeHierarchy_viewAspectRatio)
      {
        paramGenericDraweeHierarchyBuilder.setDesiredAspectRatio(localTypedArray.getFloat(n, 0.0F));
      }
      else if (n == R.styleable.GenericDraweeHierarchy_placeholderImageScaleType)
      {
        paramGenericDraweeHierarchyBuilder.setPlaceholderImageScaleType(getScaleTypeFromXml(localTypedArray, n));
      }
      else if (n == R.styleable.GenericDraweeHierarchy_retryImage)
      {
        paramGenericDraweeHierarchyBuilder.setRetryImage(getDrawable(paramContext, localTypedArray, n));
      }
      else if (n == R.styleable.GenericDraweeHierarchy_retryImageScaleType)
      {
        paramGenericDraweeHierarchyBuilder.setRetryImageScaleType(getScaleTypeFromXml(localTypedArray, n));
      }
      else if (n == R.styleable.GenericDraweeHierarchy_failureImage)
      {
        paramGenericDraweeHierarchyBuilder.setFailureImage(getDrawable(paramContext, localTypedArray, n));
      }
      else if (n == R.styleable.GenericDraweeHierarchy_failureImageScaleType)
      {
        paramGenericDraweeHierarchyBuilder.setFailureImageScaleType(getScaleTypeFromXml(localTypedArray, n));
      }
      else if (n == R.styleable.GenericDraweeHierarchy_progressBarImageScaleType)
      {
        paramGenericDraweeHierarchyBuilder.setProgressBarImageScaleType(getScaleTypeFromXml(localTypedArray, n));
      }
      else if (n == R.styleable.GenericDraweeHierarchy_progressBarAutoRotateInterval)
      {
        i = localTypedArray.getInteger(n, i);
      }
      else if (n == R.styleable.GenericDraweeHierarchy_backgroundImage)
      {
        paramGenericDraweeHierarchyBuilder.setBackground(getDrawable(paramContext, localTypedArray, n));
      }
      else if (n == R.styleable.GenericDraweeHierarchy_overlayImage)
      {
        paramGenericDraweeHierarchyBuilder.setOverlay(getDrawable(paramContext, localTypedArray, n));
      }
      else if (n == R.styleable.GenericDraweeHierarchy_roundAsCircle)
      {
        getRoundingParams(paramGenericDraweeHierarchyBuilder).setRoundAsCircle(localTypedArray.getBoolean(n, false));
      }
      else if (n == R.styleable.GenericDraweeHierarchy_roundedCornerRadius)
      {
        j = localTypedArray.getDimensionPixelSize(n, j);
      }
      else if (n == R.styleable.GenericDraweeHierarchy_roundTopLeft)
      {
        bool1 = localTypedArray.getBoolean(n, bool1);
      }
      else if (n == R.styleable.GenericDraweeHierarchy_roundTopRight)
      {
        bool2 = localTypedArray.getBoolean(n, bool2);
      }
      else if (n == R.styleable.GenericDraweeHierarchy_roundBottomLeft)
      {
        bool3 = localTypedArray.getBoolean(n, bool3);
      }
      else if (n == R.styleable.GenericDraweeHierarchy_roundBottomRight)
      {
        bool4 = localTypedArray.getBoolean(n, bool4);
      }
      else if (n == R.styleable.GenericDraweeHierarchy_roundWithOverlayColor)
      {
        getRoundingParams(paramGenericDraweeHierarchyBuilder).setOverlayColor(localTypedArray.getColor(n, 0));
      }
      else if (n == R.styleable.GenericDraweeHierarchy_roundingBorderWidth)
      {
        getRoundingParams(paramGenericDraweeHierarchyBuilder).setBorderWidth(localTypedArray.getDimensionPixelSize(n, 0));
      }
      else if (n == R.styleable.GenericDraweeHierarchy_roundingBorderColor)
      {
        getRoundingParams(paramGenericDraweeHierarchyBuilder).setBorderColor(localTypedArray.getColor(n, 0));
      }
      else if (n == R.styleable.GenericDraweeHierarchy_roundingBorderPadding)
      {
        getRoundingParams(paramGenericDraweeHierarchyBuilder).setPadding(localTypedArray.getDimensionPixelSize(n, 0));
        break label790;
        label665: localTypedArray.recycle();
        if ((paramGenericDraweeHierarchyBuilder.getProgressBarImage() != null) && (i > 0))
          paramGenericDraweeHierarchyBuilder.setProgressBarImage(new AutoRotateDrawable(paramGenericDraweeHierarchyBuilder.getProgressBarImage(), i));
        RoundingParams localRoundingParams;
        float f1;
        float f2;
        label730: float f3;
        if (j > 0)
        {
          localRoundingParams = getRoundingParams(paramGenericDraweeHierarchyBuilder);
          if (!bool1)
            break label766;
          f1 = j;
          if (!bool2)
            break label772;
          f2 = j;
          if (!bool4)
            break label778;
          f3 = j;
          label740: if (!bool3)
            break label784;
        }
        label772: label778: label784: for (float f4 = j; ; f4 = 0.0F)
        {
          localRoundingParams.setCornersRadii(f1, f2, f3, f4);
          return paramGenericDraweeHierarchyBuilder;
          label766: f1 = 0.0F;
          break;
          f2 = 0.0F;
          break label730;
          f3 = 0.0F;
          break label740;
        }
      }
      label790: m++;
    }
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.facebook.drawee.generic.GenericDraweeHierarchyInflater
 * JD-Core Version:    0.6.2
 */